<!--conf
<sample>
              <product version="1.4" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               </sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Move row by API</title>
	<meta name="KEYWORDS" content="dhtmlxgrid, dhtml grid, javascript grid, javascript, DHTML, grid, grid control, dynamical scrolling, xml, AJAX, API, cross-browser, checkbox, XHTML, compatible, gridview, navigation, script, javascript navigation, web-site, dynamic, javascript grid, dhtml grid, dynamic grid, item, row, cell, asp, .net, jsp, cold fusion, custom tag, loading, widget, checkbox, drag, drop, drag and drop, component, html">
</head>

<body>
<link rel='STYLESHEET' type='text/css' href='../common/style.css'>
<table cellspacing="0" cellpadding="0" class="sample_header" border="0">
	<tr valign="middle">
		<!-- COMPONENT ICON -->
		<td width="40" align="center"><img src="../common/dhtmlxgrid_icon.gif" border="0"></td>
		<!-- COMPONENT NAME -->
		<td width="150" align="left" nowrap="true">Sample: dhtmlxGrid</td>
		<!-- SAMPLE TITLE -->
		<td width="0" align="left" nowrap><b>Move row by API</b></td>
		<!-- LINK TO COMPONENT PAGE -->
		<td width="0" align="right"><a href="http://www.dhtmlx.com/docs/products/dhtmlxGrid/index.shtml">dhtmlxGrid main page</a></td>
		<!-- CLOSE BUTTON -->
		<td width="50"><div class="sample_close"><a href="javascript:void(0);" onclick="self.close();"><img src="../common/sample_close.gif" width="14" height="14" border="0" alt="X"></a></div></td>
	</tr>
</table>
	
	

	<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
	<script  src="../../codebase/dhtmlxcommon.js"></script>
	<script  src="../../codebase/dhtmlxgrid.js"></script>		
	<script  src="../../codebase/dhtmlxgridcell.js"></script>
	<script  src="../../codebase/ext/dhtmlxgrid_drag.js"></script>
	<table width="800">
		<tr>
			<td>
				<div id="gridbox" width="600px" height="250px" style="background-color:white;"></div>
			</td>
            <td>
    <div><a href='#' onclick='if(!mygrid.getSelectedId()) alert("A row is not selected"); else mygrid.moveRow(mygrid.getSelectedId(),"up")'>Move selected row up</a></div>
    <div><a href='#' onclick='if(!mygrid.getSelectedId()) alert("A row is not selected"); else mygrid.moveRow(mygrid.getSelectedId(),"down")'>Move selected  row down</a></div>
    <div><a href='#' onclick='if(!mygrid.getSelectedId()) alert("A row is not selected"); else mygrid.moveRow(mygrid.getSelectedId(),"row_sibling",mygrid2.getSelectedId(),mygrid2)'>Move selected  row after selected row in grid [2]</a></div>
            </td>
		</tr>
		<tr>
			<td>
				<div id="gridbox2" width="600px" height="250px" style="background-color:white;"></div>
			</td>
            <td>
    <div><a href='#' onclick='if(!mygrid2.getSelectedId()) alert("A row is not selected"); else mygrid2.moveRow(mygrid2.getSelectedId(),"up")'>Move selected row up</a></div>
    <div><a href='#' onclick='if(!mygrid2.getSelectedId()) alert("A row is not selected"); else mygrid2.moveRow(mygrid2.getSelectedId(),"down")'>Move selected  row down</a></div>
    <div><a href='#' onclick='if(!mygrid2.getSelectedId()) alert("A row is not selected"); else mygrid2.moveRow(mygrid2.getSelectedId(),"row_sibling",mygrid.getSelectedId(),mygrid)'>Move selected  row after selected row in grid [1]</a></div>
            </td>
		</tr>
			<td>&nbsp;</td>
		</tr>
	</table>

<br>
<div class='sample_code'><div class="hl-main"><pre><span class="hl-code"> 
        </span><span class="hl-identifier">mygrid2</span><span class="hl-code">.</span><span class="hl-identifier">moveRow</span><span class="hl-brackets">(</span><span class="hl-identifier">mygrid2</span><span class="hl-code">.</span><span class="hl-identifier">getSelectedId</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">up</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment">Move selected row up</span><span class="hl-comment"></span><span class="hl-code">
        </span><span class="hl-identifier">mygrid2</span><span class="hl-code">.</span><span class="hl-identifier">moveRow</span><span class="hl-brackets">(</span><span class="hl-identifier">mygrid2</span><span class="hl-code">.</span><span class="hl-identifier">getSelectedId</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">down</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment">Move selected  row down</span><span class="hl-comment"></span><span class="hl-code">
        </span><span class="hl-identifier">mygrid2</span><span class="hl-code">.</span><span class="hl-identifier">moveRow</span><span class="hl-brackets">(</span><span class="hl-identifier">mygrid2</span><span class="hl-code">.</span><span class="hl-identifier">getSelectedId</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-quotes">&quot;</span><span class="hl-string">row_sibling</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">getSelectedId</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-identifier">mygrid</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment">Move selected  row after selected row in another grid</span><span class="hl-comment"></span></pre></div></div>

<script>
  function buildGrid(mygrid){
	mygrid.setImagePath("../../codebase/imgs/");
	mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
	mygrid.setInitWidths("50,150,100,80,80,80,80,200")
	mygrid.setColAlign("right,left,left,right,center,left,center,center")
	mygrid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
    mygrid.getCombo(5).put(2,2);
	mygrid.setColSorting("int,str,str,int,str,str,str,date")
	mygrid.setColumnColor("white,#d5f1ff,#d5f1ff")
	mygrid.init();
	mygrid.loadXML("grid.xml");
  }
	mygrid = new dhtmlXGridObject('gridbox');
    buildGrid(mygrid);
   	mygrid2 = new dhtmlXGridObject('gridbox2');
    buildGrid(mygrid2);
</script>

<!-- FOOTER -->
<table callspacing="0" cellpadding="0" border="0" class="sample_footer"><tr><td style="padding-left: 8px;">&copy; <a href="http://www.dhtmlx.com">DHTMLX LTD</a>. All rights reserved</td></tr></table>
<!-- FOOTER -->

</body>
</html>
